use serde::Deserialize;
use std::collections::HashMap;
use std::fs;

#[derive(Deserialize)]
pub struct Message {
    role: String,
    content: String,
}

#[derive(Deserialize)]
pub struct PromptsConfig {
    messages: Vec<Message>,
}

pub fn read_messages_from_toml(file_path: &str) -> Vec<HashMap<String, String>> {
    let contents = fs::read_to_string(file_path).expect("Failed to read TOML file");
    let config: PromptsConfig = toml::from_str(&contents).expect("Failed to parse TOML");

    config
        .messages
        .iter()
        .map(|msg| {
            let mut map = HashMap::new();
            map.insert("role".to_string(), msg.role.clone());
            map.insert("content".to_string(), msg.content.clone());
            map
        })
        .collect()
}
